package com.dk.task;

import java.util.concurrent.Callable;

/**
 * 线程的实现方式三 实现Callable<V>接口
 * 扩展性比直接继承Thread类高
 * 可以获取线程执行的结果
 */
public class MyThread03 implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            sum = sum + i;
        }
        System.out.println(Thread.currentThread().getName() + "=" + sum);
        return sum;
    }
}
